/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Controllers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 *
 * @author BENSON
 */
public class ControllerListAdmins {
     /**
     * Variable declarations
     * View declarations
    */
    public Views.ListAdmins  displayAdmin;
    private ActionListener actionListener;
    Model.MainModel model;
    
    /**
     * Constructor for instantiating declared objects and views
     */
    
    public ControllerListAdmins(){
        displayAdmin = new Views.ListAdmins();
        displayAdmin.setVisible(true);
        model=new Model.MainModel();
    }   
    
    /**
     * Control adds actionListener to clicked buttons
     */
    
     public void control(){        
        actionListener = new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent actionEvent) {  
                  if(actionEvent.getSource()==displayAdmin.getListBtn()){
                        model.listAdmins(displayAdmin);
                  }
                  if(actionEvent.getSource()==displayAdmin.getCloseBtn()){
                  displayAdmin.setVisible(false);
                  }
              }
              
        };                
        displayAdmin.getListBtn().addActionListener(actionListener);
        displayAdmin.getCloseBtn().addActionListener(actionListener);
    }
     
    
}
